//
//  LzwBanguCollectCell.m
//  CoJellyCartoon
//
//  Created by 刘志武 on 16/4/6.
//  Copyright © 2016年 CJG. All rights reserved.
//

#import "LzwBanguCollectCell.h"

@interface LzwBanguCollectCell ()

@property (nonatomic, strong) UIImageView *myImageView;
@property (nonatomic, strong) UILabel *lableName;
@property (nonatomic, strong) UILabel *lableContent;

@end

@implementation LzwBanguCollectCell

-(instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        [self creatCollect];
    }
    return self;
}

- (void)creatCollect{
    
    self.myImageView = [[UIImageView alloc]init];
    self.myImageView.layer.masksToBounds = YES;
    self.myImageView.layer.cornerRadius = 20;
    [self.contentView addSubview:self.myImageView];
    
    self.lableName = [[UILabel alloc]init];
    self.lableName.text = @"评论人";
    [self.contentView addSubview:self.lableName];
    
    self.lableContent = [[UILabel alloc]init];
    self.lableContent.numberOfLines = 0;
    self.lableContent.font = [UIFont systemFontOfSize:15];
    self.lableContent.textAlignment = 1;
    [self.contentView addSubview:self.lableContent];
    
    
    [self.myImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(self.contentView).offset(10);
        make.width.height.mas_equalTo(40);
        
    }];
    
    [self.lableName mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.contentView).offset(30);
        make.left.equalTo(self.myImageView.mas_right).offset(10);
        make.width.mas_equalTo(150);
        make.height.mas_equalTo(20);
        
    }];
    
    [self.lableContent mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.myImageView.mas_bottom).offset(5);
        make.left.width.equalTo(self.contentView);
        //自定义
        make.height.mas_equalTo(80);
    }];
    
    
    
}

- (void)setModelP:(LzwPLModel *)modelP{
    
    _modelP = modelP;
    
    NSURL *url = [NSURL URLWithString:[_modelP.member objectForKey:@"avatar"]];
    
    [self.myImageView sd_setImageWithURL:url placeholderImage:nil];
    
    
    self.lableName.text = [_modelP.member objectForKey:@"uname"];
    
    self.lableContent.text = [_modelP.content objectForKey:@"message"];
    
}

//-(void)layoutSubviews{
//    
//    [super layoutSubviews];
//    
//    self.myImageView.frame = CGRectMake(10, 10, 60, 60);
//    self.lableName.frame = CGRectMake(80, 30, 150, 20);
//    self.lableContent.frame = CGRectMake(0, CGRectGetMaxY(self.myImageView.frame), SCREEN_WIDTH, _modelP.sizeHeight);
//    
////    //(@"%f", _modelP.sizeHeight);
//    
//}


@end
